package upbeat.jmusiclib;

import java.util.LinkedList;

import upbeat.types.Measure;

public class JMusicWrapperPrinter implements JMusicWrapperInterface {

	private LinkedList<LinkedList<Measure>> score = new LinkedList<LinkedList<Measure>>();
	private int currentMeasure = 1;
	@Override
	public void AppendNextMeasure(LinkedList<Measure> newMeasure) {

		System.out.println("----Measure: " + currentMeasure + " --------");
		for (Measure m : newMeasure) {
			System.out.println(m);
		}
		System.out.println("----------------------------------");
		
		score.add(newMeasure);
		currentMeasure++;
	}

	/**
	 * Fetch the length from the file name
	 * the file name should looks like "melody.mid.4"
	 */
	@Override
	public int length(String fileName) {
		try 
		{
			return Integer.parseInt(fileName.split(".")[2]);
		} catch (Exception e) {
			return 1;
		}
	}

	@Override
	public void play() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setTempo(int tempo) {
		// TODO Auto-generated method stub
		
	}

}
